package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CommunityRoomResident;
import com.ruoyi.system.service.ICommunityRoomResidentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * roomsResidentController
 * 
 * @author yhb
 * @date 2024-03-29
 */
@RestController
@RequestMapping("/system/roomsResident")
public class CommunityRoomResidentController extends BaseController
{
    @Autowired
    private ICommunityRoomResidentService communityRoomResidentService;

    /**
     * 查询roomsResident列表
     */
    @PreAuthorize("@ss.hasPermi('system:roomsResident:list')")
    @GetMapping("/list")
    public TableDataInfo list(CommunityRoomResident communityRoomResident)
    {
        startPage();
        List<CommunityRoomResident> list = communityRoomResidentService.selectCommunityRoomResidentList(communityRoomResident);
        return getDataTable(list);
    }

    /**
     * 导出roomsResident列表
     */
    @PreAuthorize("@ss.hasPermi('system:roomsResident:export')")
    @Log(title = "roomsResident", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CommunityRoomResident communityRoomResident)
    {
        List<CommunityRoomResident> list = communityRoomResidentService.selectCommunityRoomResidentList(communityRoomResident);
        ExcelUtil<CommunityRoomResident> util = new ExcelUtil<CommunityRoomResident>(CommunityRoomResident.class);
        util.exportExcel(response, list, "roomsResident数据");
    }

    /**
     * 获取roomsResident详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:roomsResident:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(communityRoomResidentService.selectCommunityRoomResidentById(id));
    }

    /**
     * 新增roomsResident
     */
    @PreAuthorize("@ss.hasPermi('system:roomsResident:add')")
    @Log(title = "roomsResident", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CommunityRoomResident communityRoomResident)
    {
        return toAjax(communityRoomResidentService.insertCommunityRoomResident(communityRoomResident));
    }

    /**
     * 修改roomsResident
     */
    @PreAuthorize("@ss.hasPermi('system:roomsResident:edit')")
    @Log(title = "roomsResident", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CommunityRoomResident communityRoomResident)
    {
        return toAjax(communityRoomResidentService.updateCommunityRoomResident(communityRoomResident));
    }

    /**
     * 删除roomsResident
     */
    @PreAuthorize("@ss.hasPermi('system:roomsResident:remove')")
    @Log(title = "roomsResident", businessType = BusinessType.DELETE)
	@PostMapping("del")
    public AjaxResult remove(@RequestBody CommunityRoomResident communityRoomResident)
    {
        return toAjax(communityRoomResidentService.deleteCommunityRoomResidentByIds(communityRoomResident));
    }
}
